﻿using IdentityService.Domain.Aggregates.RoleAggregate;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace IdentityService.Infrastructure.EntitiesConfig
{
    public class RoleConfig : IEntityTypeConfiguration<Role>
    {
        public void Configure(EntityTypeBuilder<Role> builder)
        {
            builder.HasKey(it => it.Id);
            builder.Property(it => it.Id).ValueGeneratedNever();

            builder.HasMany(it => it.UserAccounts).WithMany(it => it.Roles);
            builder.HasMany(it => it.Permits).WithOne().OnDelete(DeleteBehavior.Cascade);
            //builder.HasMany(it => it.Claims).WithOne().HasForeignKey(it => it.RoleId).IsRequired();
        }
    }
}
